package com.hk.commons.img;

import lombok.Data;
import lombok.experimental.Accessors;

import java.awt.*;
import java.util.Objects;

/**
 * 背景色绘制
 *
 * @author Kevin
 */
@Data
@Accessors(chain = true)
public class BackgroundCell implements MergeCell {

    private Color color;

    private int x, y;

    private int w, h;

    /**
     * 背景圆角参数
     */
    private Integer arcWidth, arcHeight;

    @Override
    public void draw(Graphics2D g2d) {
        g2d.setColor(color);
        if (Objects.nonNull(arcWidth) && Objects.nonNull(arcHeight)) {
            g2d.fillRoundRect(x, y, w, h, arcWidth, arcHeight);
        } else {
            g2d.fillRect(x, y, w, h);
        }
    }

}
